<!doctype html><!--声明文档类型：html-->
<html lang="en">
	<head><!--头部-->
		<meta charset="UTF-8">
		<title>Document</title>
<!--		<link rel="stylesheet" href="css/public.css" />-->
	    <link rel="stylesheet" href="../../../layui/css/layui.css" media="all" />
	    <script type="text/javascript" src='../../../js/jquery-1.11.1.js'></script>
	    <script type="text/javascript" src="../../../layui/layui.js"></script>
	    <script src='../../../js/yudi.js'></script>
		<script src="../../../js/ip.js"></script>
		<script src="../../../js/jquery.cookie.js"></script>
		<style type="text/css">
			*{
				margin:0;
				padding:0;
			}
			html,body{
				height:100%;
			}
			canvas{
				/*width:500px;
				height:500px;*/
				position: relative;
				background:#000;
				display:block;
			}
			.box{
				position: absolute;
				top: 50%;
				left:50%;
				margin-left: -200px;
				margin-top: -160px;
				width: 400px;
				height: 320px;
				background:#fff;
	            border-radius: 5px;
	            box-sizing: border-box;
	            box-shadow: 0 0 20px #83b6e3;
	            background-color: rgba(255,255,255,0.9);
			}
			.box-top{
	            /*width:100%;*/
	            height: 50px;
/*	            border-bottom: 2px solid #83b6e3;*/
	        }
	        .login, .regist{
	            width: 200px;
	            text-align: center;
	            color: #333;
	        }
	        .layui-tab-title li{
	        	width: 40%;
	        }
	        label.layui-form-label {
			    margin-left: 40px;
			}
			button.layui-btn{
				width: 140px;
				margin-left: 40px;
				margin-top: 15px;
			}
			.layui-tab-content {
			    margin-top: 25px;
			}
		</style>
	</head>
	<body style="background-color: #ccc"><!--身体-->
		<!--<canvas id="canvas">您的浏览器不支持cnavas标签，请您更换浏览器!!</canvas>-->
		<div class="box">
	              <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
	                  <ul class="layui-tab-title">
	                      <li class="layui-this">快速登录</li>
	                      <li>快速注册</li>
	                  </ul>
	                  <div class="layui-tab-content" style="height: 100px;">
	                      <div class="layui-tab-item layui-show">
	                      	<form class="layui-form layui-form-pane" action="">
								  <div class="layui-form-item">
									    <label class="layui-form-label">用户名</label>
									    <div class="layui-input-inline">
									      <input type="text" name="name" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input name">
									    </div>
								  </div>
								  <div class="layui-form-item">
									    <label class="layui-form-label">密码</label>
									    <div class="layui-input-inline">
									      <input type="password" name="pass" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input pass">
									    </div>
								  </div>
								  <div class="layui-form-item">
								    <button class="layui-btn login" lay-submit="" lay-filter="login">登录</button>
								    <button class="layui-btn ayui-btn-primary" type="reset" lay-filter="demo2">重置</button>
								  </div>
							</form>
	                      </div>
	                      <div class="layui-tab-item">
	                          <form class="layui-form layui-form-pane" action="">
									  <div class="layui-form-item">
										    <label class="layui-form-label">用户名</label>
										    <div class="layui-input-inline">
										      <input type="text" name="username" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input username">
										    </div>
									  </div>
									  <div class="layui-form-item">
										    <label class="layui-form-label">密码</label>
										    <div class="layui-input-inline">
										      <input type="password" name="password" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input password">
										    </div>
									  </div>
									  <div class="layui-form-item">
										    <label class="layui-form-label">确认密码</label>
										    <div class="layui-input-inline">
										      <input type="password" name="password" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input repeat-password">
										    </div>
									  </div>
									  <div class="layui-form-item">
									       <button class="layui-btn regist" lay-submit="" lay-filter="regist">注册</button>
									       <button class="layui-btn ayui-btn-primary" type="reset">重置</button>
								            <p class="info" style="text-align: center; color: #fff;"></p>
									  </div>
							  </form>
	                      </div>
	                  </div>
	              </div>
         </div>
		<script type="text/javascript">
			layui.use(['layer','form','laypage','element'], function(){
	              var $ = layui.jquery,
			            layer = layui.layer,
			            element = layui.element,
			            form=layui.form,
			            laypage=layui.laypage;
	              $('.site-demo-active').on('click', function(){
	                  var othis = $(this), type = othis.data('type');
	                  active[type] ? active[type].call(this, othis) : '';
	              });
	              
                  $('.repeat-password').blur(function(){
                  	if($(this).val() !== $('.password').val()){
                  		layer.msg('两次密码输入的不一致，请重新输入！！！');
                  		$(this).val('');
                  	}
                  });
        			form.on('submit(regist)', function (data) {
        				var username = $('.username').val();
        				var password = $('.password').val();

	                    $.ajax({
	                        type: "POST",
	                        data: {
	                            userName: username,
	                            password: password,
	                        },
	                        url: api+"loms/mg/register",
	                        success: function(result){
	                        	console.log(result);
	                            if(result.code == 1){
	                            	layer.msg("注册成功,请登录");
	                            	setTimeout(function(){
	                                    location.href = 'login.html';
	                            	},1700);
	                            }else{
	                                $('.info').html(result.message);
	                            }
	                        }
	                    })
                        return false;
                  });
                  form.on('submit(login)', function (data) {
        				var username = $('.name').val();
        				var password = $('.pass').val();
	                    $.ajax({
	                        type: "POST",
	                        data: {
	                            userName: username,
	                            password: password,
	                        },
	                        url: api+"loms/mg/login",
	                        success: function(result){
	                            if(result.code == 1){
	                                   $.cookie('token', result.data, { expires: 7, path: '/' });
	                            	   $.ajax({
								            type: "GET",
								            headers: {
								                token :  $.cookie('token')
								            },
								            url: api+"loms/mg/business/my",
								            success: function(result){
								                console.log($.cookie('token'));
								            }
								        });
	                                   location.href = '../../index.html';
	                            }else{
                                    top.layer.msg(result.message);
	                            }	                            
	                        }
	                    })
                        return false;
                  });
          });
			
		</script>
	</body>
</html>
